//
//  ControllerPushAnimator.m
//  MyFunctionDemo
//
//  Created by Ting Han on 2017/9/1.
//  Copyright © 2017年 Ting Han. All rights reserved.
//

#import "ControllerPushAnimator.h"
#import "UIView+SetRect.h"
#import "UIView+AnimationProperty.h"

@implementation ControllerPushAnimator
- (void)transitionAnimation {
    
    // http://stackoverflow.com/questions/25588617/ios-8-screen-blank-after-dismissing-view-controller-with-custom-presentation
    [self.containerView addSubview:self.toViewController.view];
    
    // ViewController *controller = (ViewController *)self.fromViewController;
    
    self.toViewController.view.x = [UIScreen mainScreen].bounds.size.width;
    [UIView animateWithDuration:self.transitionDuration - 0.1f delay:0.f options:UIViewAnimationOptionCurveEaseInOut animations:^{
       // controller.view.alpha = 0.f;
        self.fromViewController.view.alpha        = 0.f;
        self.toViewController.view.x = 0;
        
    } completion:^(BOOL finished) {
        
       // controller.view.alpha = 1.f;
        self.fromViewController.view.alpha = 1.f;
        [self completeTransition];
    }];
}

@end
